package com.umakr.ax.app.web;

import com.baomidou.mybatisplus.plugins.Page;
import com.umakr.ax.common.model.InteractiveLottery;
import com.umakr.ax.common.service.LotteryResultService;
import com.umakr.ax.core.base.AbstractController;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.Date;
import java.util.List;

/**
 * 抽奖结果
 * Created by umakr on 2018/5/5.
 * @author zj
 */
@Controller
@RequestMapping("/api/web/lotteryResult")
public class LotteryResultController extends AbstractController {
    @Autowired
    LotteryResultService lotteryResultService;


    @ApiOperation(value = "执行抽奖操作")
    @RequestMapping("/listAndSaveLotteryResult")
    @ResponseBody
    public Object listAndSaveLotteryResult(ModelMap modelMap,
                                           @RequestParam(name = "rsId") Long rsId,
                                           @RequestParam(name = "drawUserId") Long drawUserId,
                                           @RequestParam(name = "lotteryId") Long lotteryId,
                                           @RequestParam(name = "startTime") @DateTimeFormat(pattern="yyyy/MM/dd HH:mm") Date startTime,
                                           @RequestParam(name = "endTime") @DateTimeFormat(pattern="yyyy/MM/dd HH:mm")Date endTime,
                                           @RequestParam(name = "peopleCount") Integer peopleCount,
                                           String keyWord,
                                           @RequestParam(name = "status") Integer status,
                                           Integer messageFrom) throws IOException {
        return setSuccessModelMap(modelMap,lotteryResultService.listAndSaveLotteryResult(rsId,drawUserId,lotteryId,
                startTime,endTime,peopleCount,keyWord,status,messageFrom));
    }

    @ApiOperation(value = "抽奖结果查看")
    @RequestMapping("/listLotteryResultById")
    @ResponseBody
    public Object listLotteryResultById(ModelMap modelMap, @RequestParam(name = "lotteryId") Long lotteryId,
                                        Integer totalPeople)  throws
            IOException {
        return setSuccessModelMap(modelMap,lotteryResultService.listLotteryResultById(lotteryId,totalPeople));
    }

    @ApiOperation(value = "抽奖结果保存")
    @RequestMapping("/saveLotteryResult")
    @ResponseBody
    public Object saveLotteryResult(ModelMap modelMap, @RequestParam Long lotteryId,@RequestParam long[] msgId)  throws
            IOException {
        return setSuccessModelMap(modelMap,lotteryResultService.saveLotteryResult(lotteryId,msgId));
    }

    @ApiOperation(value = "通知获奖用户")
    @RequestMapping("/informWinUser")
    @ResponseBody
    public Object informWinUser(ModelMap modelMap,@RequestParam(name = "id") String id,
                                @RequestParam Long lotteryId,
                                @RequestParam Integer informStatus)  throws IOException {
        return setSuccessModelMap(modelMap,lotteryResultService.informWinUser(id,lotteryId,informStatus));
    }

    /*@ApiOperation(value = "通知获奖用户")
    @RequestMapping("/informWinUser")
    @ResponseBody
    public Object informWinUser(ModelMap modelMap,@RequestParam Long[] id, @RequestParam Long lotteryId,@RequestParam
            long[] msgId,
                                @RequestParam long[] userId,@RequestParam long rsId, @RequestParam Integer informStatus)  throws
            IOException {
        return setSuccessModelMap(modelMap,lotteryResultService.informWinUser(id,lotteryId,msgId,userId,rsId,
                informStatus));
    }*/
}
